#! /usr/bin/env python
#coding:utf-8
import httplib,urllib,json
from scrapy.conf import settings

class MsgSend(object):
    @staticmethod  
    def send_msg(*args,**kwargs):
        httpClient = None
        url=settings.get("WEBSOCKET_URL")
        try:
            httpClient = httplib.HTTPConnection(url, 8888, timeout=30)
            httpClient.request('GET', '/getspark?name='+urllib.quote(json.dumps(kwargs)))
            response = httpClient.getresponse()
            return response.status
        except Exception, e:
            print e
            return 500
        finally:
            if httpClient:
                httpClient.close()
                
if __name__=='__main__':
    print  MsgSend.send_msg(**{"message":"start_url 不合法","code":401})



